package com.tesis_2.UI;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.example.tesis_2.R;
import com.tesis_2.BL.BLSeguridad;
import com.tesis_2.MO.User;

public class LogIn extends Activity {
	
	EditText txtUser;
	EditText txtPass;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_log_in);
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_log_in, menu);
		return true;
	}
	
	public void Ingresar(View view) throws Exception
	{ 
		txtUser= (EditText)findViewById(R.id.txtUsuario_login);
		txtPass= (EditText)findViewById(R.id.txtPass_login);
		User objUser = BLSeguridad.Login(txtUser.getText().toString(),txtPass.getText().toString());
		if ( objUser.getName() != null ) 
		{
			Intent intend = new Intent(this, Restaurants.class);
			startActivity(intend);
		}
		
		else
		{
			Toast toast = Toast.makeText(getApplicationContext(), "Acceso fallido, revise sus datos y la conexion.", Toast.LENGTH_SHORT);
			toast.show();
		}
			
		
	}

}
